package bitekeji.day2;

import java.io.*;

public class CopyFile {
    public static void main(String[] args) throws IOException {
        // 源文件：src.png
        // 目标文件：dest.png
        try (InputStream is = new FileInputStream("dest.png")) {
            try (OutputStream os = new FileOutputStream("dest2.png")) {
                byte[] buf = new byte[1024];
                while (true) {
                    int n = is.read(buf);
                    if (n == -1) {
                        break;
                    }

                    for (int i = 0; i < n; i++) {
                        buf[i] -= 1;
                    }
                    os.write(buf, 0, n);
                }
                os.flush();
            }
        }
    }
}
